package org.example;

import java.util.concurrent.TimeUnit;

public class HelloVolatile {
    volatile boolean runing = true;
    void m() {
        System.out.println("m start");
        while (runing) {};
        System.out.println("m end");
    }
    public static void main(String[] args) throws InterruptedException {
        HelloVolatile helloVolatile = new HelloVolatile();
        new Thread(helloVolatile::m, "m1").start();
        TimeUnit.SECONDS.sleep(1);
        helloVolatile.runing = false;
    }
}
